﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.UI.WebControls;

namespace crm_library.Extenstions
{
	public static class StringExtensions
	{
		public static string ConvertCamelCaseToWords(this string camelCaseString)
		{
			var r = new Regex("(?<=[a-z])(?<x>[A-Z])|(?<=.)(?<x>[A-Z])(?=[a-z])");
			var s = r.Replace(camelCaseString.Trim(), " ${x}");
			var retValue = char.ToUpper(s[0]) + s.Substring(1);

			while (retValue.Contains("  "))
			{
				retValue = retValue.Replace("  ", " ");
			}

			return retValue;
		}

		public static Literal ToLiteral(this string text)
		{
			return new Literal { Text = text };
		}

		public static Label ToLabel(this string text)
		{
			return new Label { Text = text };
		}


		public static bool Contains(this string source, string toCheck, StringComparison comp)
		{
			return source.IndexOf(toCheck, comp) >= 0;
		}

	}
}